{#
This file is part of EC-CUBE

Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.

http://www.ec-cube.co.jp/

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#}
{% extends 'default_frame.twig' %}

{% set menus = ['product', 'category_csv_import'] %}

{% block title %}商品管理{% endblock %}
{% block sub_title %}カテゴリ登録CSVアップロード{% endblock %}

{% form_theme form 'Form/bootstrap_3_horizontal_layout.html.twig' %}

{% block javascript %}
<script src="{{ app.config.admin_urlpath }}/assets/js/vendor/spin.min.js"></script>
<script>
$(function() {

    var opts = {
        lines: 13,
        length: 30,
        width: 2,
        radius: 12,
        corners: 1,
        rotate: 0,
        direction: 1,
        color: '#BBB',
        speed: 1,
        trail: 67,
        shadow: true,
        hwaccel: false,
        className: 'spinner',
        zIndex: 2e9,
        top: top
    };

    ImageSpinner = new Spinner(opts).spin(document.getElementById('spinner'));
    ImageSpinner.stop();

    $('#upload-form').submit(function() {
        $('#upload-button').attr('disabled', 'disabled');
        $('#download-button').attr('disabled', 'disabled');
        ImageSpinner.spin(document.getElementById('spinner'));
    });
});
</script>
{% endblock javascript %}

{% block main %}
<div class="row">
    <div class="col-md-12">
        <form id="upload-form" class="form-inline" method="post" action="{{ url('admin_product_category_csv_import') }}" {{ form_enctype(form) }}>
            {{ form_widget(form._token) }}
            <div id="upload_wrap" class="box">
                <div id="upload_box__header" class="box-header">
                    <h3 class="box-title">カテゴリ登録CSV</h3>
                </div><!-- /.box-header -->
                <div id="upload_box__body" class="box-body">
                    <div id="upload_box__body_inner" class="form-group">
                        <label class="col-sm-5 control-label">CSVファイル選択</label>
                        <div id="upload_box__file" class="col-sm-7">
                            {{ form_widget(form.import_file, {'attr': {'accept': 'text/csv,text/tsv'}}) }}
                            {{ form_errors(form.import_file) }}
                        </div>
                        {% for error in errors %}
                            <div id="upload_box__error" class="text-danger">{{ error.message }}</div>
                        {% endfor %}
                    </div>
                    <div id="spinner"></div>
                </div><!-- /.box-body -->
                <div class="box-footer text-center">
                    <button id="upload-button" type="submit" class="btn btn-primary btn-sm">CSVファイルのアップロード</button>
                </div><!-- /.box-footer -->
            </div><!-- /.box -->
        </form>
    </div><!-- /.col -->
</div>

<div id="file_format" class="row">
    <div id="file_format_box" class="col-md-12">
        <div id="file_format_box__body" class="box">
            <div id="file_format_box__header" class="box-header">
                <a href="{{ url('admin_product_csv_template', {'type': 'category'}) }}" id="download-button" class="btn btn-default pull-right btn-xs">雛形ファイルダウンロード</a>
                <h3 class="box-title">カテゴリ登録CSVファイルフォーマット</h3>
            </div><!-- /.box-header -->
            <div id="file_format_box__body_inner" class="box-body no-padding">
                <div id="file_format_box__list_box" class="table_list">
                    <div id="file_format_box__list_box_body" class="table-responsive no-border table-menu table-responsive-overflow">
                        <table class="table table-striped">
                            <thead>
                                <tr id="file_format_box__header" class="text-nowrap">
                                    {% for header in headers|keys %}
                                        <th id="file_format_box__header--{{ loop.index }}">{{ header }}</th>
                                    {% endfor %}
                                </tr>
                            </thead>
                            <tbody>
                                <tr id="file_format_box__list" class="text-nowrap">
                                    <td id="file_format_box__id">新規登録時は未設定<br>既存カテゴリの更新はカテゴリIDを設定</td>
                                    <td id="file_format_box__name">必須</td>
                                    <td id="file_format_box__parent_id"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </div><!-- /.col -->
</div>

{% endblock %}
